// #include "napi/native_api.h"
#include "FlowItemViewComponentInstance.h"
using namespace std;
FlowItemViewComponentInstance::FlowItemViewComponentInstance(Context context) : ComponentInstance(std::move(context)) {
    m_flowItemNode.setFlowItemNodeDelegate(this);
}

void FlowItemViewComponentInstance::onChildInserted(ComponentInstance::Shared const &childComponentInstance,
                                                    std::size_t index) {
    ComponentInstance::onChildInserted(childComponentInstance, index);
    m_flowItemNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index);
}

void FlowItemViewComponentInstance::onChildRemoved(ComponentInstance::Shared const &childComponentInstance) {
    ComponentInstance::onChildRemoved(childComponentInstance);
    m_flowItemNode.removeChild(childComponentInstance->getLocalRootArkUINode());
};

void FlowItemViewComponentInstance::onClick() {
    // todo: event
    //   if (m_eventEmitter != nullptr) {
    //     m_eventEmitter->dispatchEvent(
    //         "click", [=](facebook::jsi::Runtime& runtime) {
    //           auto payload = facebook::jsi::Object(runtime);
    //           return payload;
    //         });
    //   }
}
